﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace Application
{
    public class UserService
    {
        private void ShowUser(long userId, Action<UserModel> updateAction)
        {
            var user = GetUsers().FirstOrDefault(item => item.UserId == userId);
            updateAction(user);

            Console.WriteLine("ID:{0},Name：{1},State：{2},Time:{3}", user.UserId, user.UserName, user.State,
                user.ModifyTime);
        }


        public void DisableUser(long userId)
        {
            ShowUser(userId, (p) => p.DisableUser());
        }

        public void ShowUser(long userId)
        {
            ShowUser(userId, (p) => p.ToString());
        }

        public List<UserModel> GetUsers()
        {
            return new List<UserModel>()
            {
                new UserModel(){UserId=1001,UserName = "张三",State = "T",ModifyTime=DateTime.Now.AddDays(-1)},
                new UserModel(){UserId=1002,UserName = "李四",State = "T",ModifyTime=DateTime.Now.AddDays(-1)},
                new UserModel(){UserId=1003,UserName = "王五",State = "T",ModifyTime=DateTime.Now.AddDays(-1)}
            };
        }
    }
}
